package br.ucb.controller;

import java.io.Serializable;

import br.ucb.bean.LoginMobile;
import br.ucb.dao.LoginMobileDAO;
import br.ucb.util.SimpleEntityManager;

public class LoginMobileController extends GenericController implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private LoginMobileDAO loginMobileDAO;

	public LoginMobileDAO getLoginMobileDAO() {
		return loginMobileDAO;
	}

	public void setLoginMobileDAO(LoginMobileDAO loginMobileDAO) {
		this.loginMobileDAO = loginMobileDAO;
	}
	
	public void readyManagerAndDao() {
		setManager(new SimpleEntityManager("sacop"));
		this.loginMobileDAO = new LoginMobileDAO(getManager().getEntityManager());
		getManager().beginTransaction();
	}
	
	public LoginMobile validateMoblieLogon(LoginMobile loginMobile){
		readyManagerAndDao();
		LoginMobile temp = getLoginMobileDAO().buscarDuasColunas("usuario", "senha", loginMobile.getUsuario(), loginMobile.getSenha());
		getManager().close();
		return temp;
	}

}
